import java.util.ArrayList;
import java.util.List;

public class Student {
    private String id;
    private String name;
    private String gender;
    private List<Course> selectedCourses = new ArrayList<>();

    // 构造方法
    public Student(String id, String name, String gender) {
        this.id = id;
        this.name = name;
        this.gender = gender;
    }

    // 选课方法
    public void selectCourse(Course course) {
        if (!selectedCourses.contains(course)) {
            selectedCourses.add(course);
            System.out.println(name + "同学选了" + course.getCourseName() + "课程");
        } else {
            System.out.println(name + "同学已选过" + course.getCourseName() + "课程");
        }
    }

    // 退课方法
    public void dropCourse(Course course) {
        if (selectedCourses.contains(course)) {
            selectedCourses.remove(course);
            System.out.println(name + "同学退了" + course.getCourseName() + "课程");
        } else {
            System.out.println(name + "同学未选" + course.getCourseName() + "课程，无法退课");
        }
    }

    // 打印课表方法
    public void printCourseSchedule() {
        System.out.println(name + "同学的课表：");
        for (Course course : selectedCourses) {
            System.out.println("课程编号：" + course.getId() + "，课程名称：" + course.getCourseName() + "，上课地点：" + course.getLocation() + "，时间：" + course.getTime() + "，授课教师：" + course.getTeacher().getName());
        }
    }

    // getter 方法
    public String getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public String getGender() {
        return gender;
    }
}